using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel;

namespace Microsoft.ApplicationBlocks.Updater.Tools
{
	class EditorUtility
	{
		static OpenFileDialog _openFileDialog;

		public static OpenFileDialog OpenFileDialog
		{
			get
			{
				if (EditorUtility._openFileDialog == null)
				{
                    EditorUtility._openFileDialog = new OpenFileDialog();
				}
				return EditorUtility._openFileDialog;
			}
			set
			{
				EditorUtility._openFileDialog = value;
			}
		}

		static FolderBrowserDialog _folderBrowserDialog;

		public static FolderBrowserDialog FolderBrowserDialog
		{
			get
			{
				if (EditorUtility._folderBrowserDialog == null)
				{
					EditorUtility._folderBrowserDialog = new FolderBrowserDialog();
				}
				return EditorUtility._folderBrowserDialog;
			}
			set
			{
				EditorUtility._folderBrowserDialog = value;
			}
		}

		public static void DisplayGetFolder(string promptText, System.Windows.Forms.Control resultsReceiver)
		{
			EditorUtility.FolderBrowserDialog.Description = promptText;
			EditorUtility.FolderBrowserDialog.SelectedPath = string.Empty;
            if (DialogResult.OK == EditorUtility.FolderBrowserDialog.ShowDialog())
			{
				resultsReceiver.Text = EditorUtility.FolderBrowserDialog.SelectedPath;
			}
		}

		public static void DisplayGetPath(string promptText, System.Windows.Forms.Control resultsReceiver)
		{
			EditorUtility.OpenFileDialog.Multiselect = false;
			EditorUtility.OpenFileDialog.CheckFileExists = true;
            if (DialogResult.OK == EditorUtility.OpenFileDialog.ShowDialog())
			{
				resultsReceiver.Text = EditorUtility.OpenFileDialog.FileName;
			}
		}
	}
}
